package org.glut.AppStoreProject.service;


import org.apache.ibatis.session.SqlSession;
import org.glut.AppStoreProject.entity.AppList;
import org.glut.AppStoreProject.mapper.AppListMapper;
import org.glut.AppStoreProject.utils.MybatisUtil;
import org.apache.log4j.Logger;
import java.util.List;



public class AppListImpl {
    static Logger log = Logger.getLogger(AppList.class.getName());

    public List<AppList> getAppList() {
        try (
                SqlSession sqlSession = MybatisUtil.getSession()
        ) {
            AppListMapper appListMapper = sqlSession.getMapper(AppListMapper.class);
            return appListMapper.select(new AppList());
        } catch (Exception e) {
            log.error(e);
        }
        return null;
    }

    public List<AppList> getAppList(AppList condition) {
        try (
                SqlSession sqlSession = MybatisUtil.getSession()
        ) {
            AppListMapper appListMapper = sqlSession.getMapper(AppListMapper.class);
            return appListMapper.select(condition);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return null;
    }
}